<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <p>{{name}}</p>
    <p k-text="name"></p>
    <p>{{age}}</p>
    <p>{{doubleAge}}</p>

    <input type="text" k-model="name" />
    <button @click="changeName">呵呵</button>
    <div k-html="html"></div>
  </div>

  <script src="./compile.js"></script>
  <script src="MVue.js"></script>
  <script>
    /**
     * 
     * 在new Vue() 会调用进行初始化，初始化生命周期、事件、props、methods、data、computed与watch
     * 
     * 通过Object.defineProperty设置setter与getter,来实现响应式、依赖收集
     * 
     * 
     */
    const myapp = new MVue({
      el: '#app',
      data: {
        name: 'I am test',
        age: 12,
        html: '<button>这是一个按钮</button>'
      },
      created(){
        console.log('开始了')
        setTimeout(()=>{
          this.name = '我是测试'
        }, 1500)
      },
      methods:{
        changeName(){
          this.name = '哈喽 test',
          this.age = 1
        }
      }
    })
  </script>
</body>
</html>